package com.framework.boc.statistics.service.impl;

import com.framework.boc.statistics.entity.StatisticalBatch;
import com.framework.boc.statistics.entity.Template;
import com.framework.boc.statistics.mapper.StatisticalBatchMapper;
import com.framework.boc.statistics.service.IStatisticalBatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 统计批次表 服务实现类
 * </p>
 *
 * @author Leil
 * @since 2020-12-23
 */
@Service
public class StatisticalBatchServiceImpl extends ServiceImpl<StatisticalBatchMapper, StatisticalBatch> implements IStatisticalBatchService {

    /**
     * 新增或更新一个统计批次信息
     * @param batch     批次信息
     * @return          新增/更新结果
     */
    public boolean addOrUpdate(StatisticalBatch batch) {
        if (batch.getId() == 0) {
            batch.setId(null);
            batch.setCreateDate(new Date());
            batch.setCreateUser("admin");
        }
        boolean bool = this.saveOrUpdate(batch);
        return bool;
    }

}
